package day.day6_27;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        //去掉字符串两边的空格
        s.trim();
        //将字符串转化为字符数组
        char[] a=s.toCharArray();
        //通过reverse方法将字符数组反转
        reverse(a,0,a.length-1);
        //通过空格分隔符反转每一个单词
        int start=0;
        for (int i = 0; i <a.length ; i++) {
            if (a[i]==' '){
                reverse(a,start,i-1);
                start=i+1;
            }
        }
        reverse(a,start,a.length-1);
        System.out.println(a);
    }
    //将一个字符数组从i到j进行反转
    public static void reverse(char[] a,int i,int j){
         while (i<j){
             char temp=a[i];
             a[i]=a[j];
             a[j]=temp;
             i++;
             j--;
         }
    }
}

